﻿package plugin.roleN.controller
{
    import base.*;
    import com.core.*;
    import com.greensock.*;
    import com.sh.game.display.*;
    import com.sh.game.global.*;
    import com.sh.game.net.*;
    import com.sh.game.util.*;
    import consts.*;
    import flash.display.*;
    import flash.events.*;
    import flash.geom.*;
    import manager.*;
    import morn.core.components.*;
    import morn.core.handlers.*;
    import plugin.juezhan.model.*;
    import plugin.roleN.compoment.*;
    import plugin.roleN.model.*;
    import pluginfw.nio.*;
    import uiresource.roleui.*;
    import view.*;
    import view.message.*;
    import view.mornExtends.*;
    import view.uilt.*;
    import vo.*;

    public class BaoShiCtrl extends BaoShiPageUI
    {
        private var _itemprite:Sprite;
        private var btnSprite:Sprite;
        private var armid:int;
        private var itemArr:Array;
        private var data:Object;
        private var _alertFlag:Boolean = true;
        private var _showAlert:Boolean = false;
        private var _txtGet:Label;
        private var _txtBuy:Label;
        private var cfgitem:Object;
        private var cfgarmadd:Object;
        private var cfgGemLimit:Array;
        private var cfgStore:Object;
        private var cfgGem:Array;
        private var curSelect:int = 0;
        private var kaiqiArrs:Array;
        private var xqItemIds:Array;
        private var _sjview:BaoShiSJView;
        private var xqNum:int = 0;
        private var xqindex:int = 0;
        private var mPowerNumber:NumberComponent;
        private var img_glow:XMLMovieClip;
        private var _init:Boolean = false;
        private var hechengSprite:Sprite;
        private var hechengView:BaoShiHeChengUICtrl;
        private var _mc:XMLMovieClip;
        private var _xml1:XML;
        private var _value:Array;
        private var fgOjbs:Object;
        private var isShengji:int = 0;
        private var tipsView:BaoShiTips;
        private var _bstzTips:String;
        private var bstz:Object;
        public static const guangyiXML:Class = BaoShiCtrl_guangyiXML;

        public function BaoShiCtrl()
        {
            this.itemArr = [];
            this.cfgitem = ConfigDictionary.data.item;
            this.cfgarmadd = ConfigDictionary.data.armaddcost;
            this.cfgGemLimit = ConfigDictionary.data.gemlimit;
            this.cfgStore = ConfigDictionary.data.storeNew;
            this.cfgGem = ConfigDictionary.data.gem;
            this.kaiqiArrs = new Array();
            this.xqItemIds = new Array();
            this._value = [];
            this.fgOjbs = new Object();
            this.bstz = ConfigDictionary.data.bstz;
            return;
        }// end function

        private function init() : void
        {
            this._init = true;
            this._itemprite = new Sprite();
            this._itemprite.x = 0;
            this._itemprite.y = 0;
            this.addChild(this._itemprite);
            this.btnSprite = new Sprite();
            this.btnSprite.x = 0;
            this.btnSprite.y = 0;
            this.addChild(this.btnSprite);
            this.mPowerNumber = new NumberComponent();
            this.mPowerNumber.x = 218;
            this.mPowerNumber.y = 425 + 10;
            this.mPowerNumber.number = 0;
            this.addChild(this.mPowerNumber);
            this.tipsView = new BaoShiTips();
            this.tipsView.visible = false;
            this.addChild(this.tipsView);
            this.hechengSprite = new Sprite();
            this.addChild(this.hechengSprite);
            var _loc_1:int = 1;
            while (_loc_1 <= 10)
            {
                
                (this["pos_" + _loc_1] as Box).filters = [FilterDefine.grayFilter];
                _loc_1++;
            }
            this.initEvent();
            this.showGouMaiItem();
            this.doShow(this.curSelect);
            return;
        }// end function

        override protected function initializeView() : void
        {
            super.initializeView();
            XMLMcManager.instance.complatefuncs["role"] = this.completeFunc;
            this._xml1 = new XML(new guangyiXML());
            App.mloader3.loadSWF(Config.getUrl("assets/images/mainui/guangyi.swf"), 1, new Handler(this.hcCompleteFunc));
            this.init();
            baoshibg.url = null;
            return;
        }// end function

        private function hcCompleteFunc(param1:Object) : void
        {
            this._mc = new XMLMovieClip("png.guangyi", this._xml1);
            this._mc.mouseChildren = false;
            this._mc.mouseEnabled = false;
            this._mc.visible = false;
            this._mc.x = 405 - 138 - 119;
            this._mc.y = 257 - 300 + 28;
            this._mc.play();
            this.addChild(this._mc);
            return;
        }// end function

        private function completeFunc() : void
        {
            this.clearSelectEffect();
            this.img_glow = XMLMcManager.instance.getPluginMc("role", "baoshi");
            if (this.img_glow)
            {
                this.img_glow.blendMode = BlendMode.ADD;
                this.img_glow.play();
                this.img_glow.mouseEnabled = false;
                this.img_glow.x = -96;
                this.img_glow.y = -54;
                if (this.kaiqiArrs.length == 0)
                {
                    this.img_glow.visible = false;
                }
                else
                {
                    this.img_glow.visible = true;
                }
                this.addChild(this.img_glow);
            }
            return;
        }// end function

        private function initEvent() : void
        {
            this.addEventListener(MouseEvent.CLICK, this.doClick);
            img_tips.addEventListener(MouseEvent.ROLL_OVER, this.overHandler);
            img_tips.addEventListener(MouseEvent.ROLL_OUT, this.outHandler);
            var _loc_1:int = 1;
            while (_loc_1 <= 10)
            {
                
                this["pos_" + _loc_1].addEventListener(MouseEvent.ROLL_OVER, this.overHandler);
                this["pos_" + _loc_1].addEventListener(MouseEvent.ROLL_OUT, this.outHandler);
                _loc_1++;
            }
            closebtn.addEventListener(MouseEvent.CLICK, this.closeHandler);
            bagList.renderHandler = new Handler(this.bagListRender, [this]);
            bagList.selectHandler = new Handler(this.selectHadler);
            goumaiList.renderHandler = new Handler(this.goumaiRender);
            hechengBtn.addEventListener(MouseEvent.CLICK, this.hechengHandler);
            return;
        }// end function

        private function selectHadler(param1:int) : void
        {
            var _loc_2:Output = null;
            ModelProxy.change("guide", "hide", GuideType.GUIDE_LINSHI);
            if (bagList.selectedItem)
            {
                _loc_2 = new Output();
                _loc_2.writeVarInt(bagList.selectedItem.itemid, false);
                _loc_2.writeVarInt(this.curSelect, false);
                PluginManager.instance.sendToBufferServer("baoshi", CMDBaoShi.XiangQian, _loc_2);
            }
            bagList.selectedIndex = -1;
            this.isShengji = 0;
            return;
        }// end function

        public function openRefresh() : void
        {
            if (this.img_glow)
            {
                if (this.kaiqiArrs.length == 0)
                {
                    this.img_glow.visible = false;
                }
                else
                {
                    this.img_glow.visible = true;
                }
            }
            var _loc_1:* = PluginManager.instance.getGroupId("juezhan");
            Server.instance.send(_loc_1, CMDJueZhan.TIAN_GUAN_PROGRESS, null);
            if (this._init == false)
            {
                this.init();
            }
            rightBox.visible = true;
            hechengBtn.visible = true;
            baoshibg.url = "cs2_roleN/bg1.jpg";
            this.showBagItem();
            this.completeFunc();
            this.doShow(this.curSelect);
            return;
        }// end function

        public function showBaoShiInfo(param1:Array) : void
        {
            this.kaiqiArrs = param1;
            if (this.img_glow)
            {
                if (this.kaiqiArrs.length == 0)
                {
                    this.img_glow.visible = false;
                }
                else
                {
                    this.img_glow.visible = true;
                }
            }
            var _loc_2:int = 0;
            while (_loc_2 < this.kaiqiArrs.length)
            {
                
                (this["pos_" + (this.kaiqiArrs[_loc_2].pos + 1)] as Box).filters = null;
                if (this.curSelect == _loc_2 && this.kaiqiArrs[_loc_2].itemidList.length > 0)
                {
                    this.showItem(this.kaiqiArrs[_loc_2].itemidList);
                }
                this.xqItemIds[this.kaiqiArrs[_loc_2].pos] = this.kaiqiArrs[_loc_2].itemidList;
                _loc_2++;
            }
            this.showMask();
            this.showNBvalue();
            return;
        }// end function

        public function openItem(param1:Object) : void
        {
            (this["pos_" + (param1.pos + 1)] as Box).filters = null;
            var _loc_2:* = new Object();
            _loc_2.pos = param1.pos;
            _loc_2.itemidList = [0, 0, 0, 0, 0, 0];
            this.kaiqiArrs[param1.pos] = _loc_2;
            return;
        }// end function

        public function changeBaoShiInfo(param1:Object) : void
        {
            var _loc_2:Array = [];
            var _loc_3:int = 0;
            while (_loc_3 < this.kaiqiArrs.length)
            {
                
                if (param1.pos == this.kaiqiArrs[_loc_3].pos)
                {
                    if (this.kaiqiArrs[_loc_3].itemidList)
                    {
                        _loc_2 = this.kaiqiArrs[_loc_3].itemidList;
                    }
                    if (param1.itemid == 0)
                    {
                        _loc_2[param1.index] = 0;
                    }
                    else
                    {
                        _loc_2[param1.index] = param1.itemid;
                    }
                    this.xqItemIds[param1.pos] = _loc_2;
                    this.showItem(_loc_2);
                }
                _loc_3++;
            }
            ModelProxy.change("data", "BaoshiCount", this.xqItemIds);
            ModelProxy.change("role", "showBaoshiCount", null);
            ModelProxy.change("mainview", "showBaoshiCount", null);
            this.showNBvalue();
            return;
        }// end function

        public function updateShengji(param1:Object) : void
        {
            if (!param1.itemid)
            {
                return;
            }
            this.sjview.showSuccessEffect();
            if (this.isShengji == 1)
            {
                if (int(this.cfgitem[param1.itemid].level) == 10)
                {
                    ModelProxy.change("movetips", "error", "该宝石已升级到最高等级");
                    this.sjview.visible = false;
                    this.sjview.clear();
                    return;
                }
            }
            if (this.sjview.visible)
            {
                this.sjview.showItem(param1.itemid);
                this.shengjiHandler(param1.itemid, param1.index);
            }
            return;
        }// end function

        public function showUpdateItem() : void
        {
            if (this._value && this._value.length > 0)
            {
                this.showItem(this._value);
            }
            return;
        }// end function

        private function showItem(param1:Array) : void
        {
            var aa:XiangQianItem;
            var j:int;
            var btn:Button;
            var count:int;
            var value:* = param1;
            this._value = value;
            var arr1:Array;
            var m:int;
            while (m < 6)
            {
                
                if (value && value[m] != 0)
                {
                    arr1.push(value[m]);
                }
                m = (m + 1);
            }
            this.xqNum = arr1.length;
            while (this._itemprite.numChildren > 0)
            {
                
                this._itemprite.removeChildAt(0);
            }
            while (this.btnSprite.numChildren > 0)
            {
                
                this.btnSprite.removeChildAt(0);
            }
            var itemXY:Array;
            var btnXY:Array;
            var nbvalue:int;
            var i:int;
            while (i < 6)
            {
                
                aa = new XiangQianItem();
                aa.index = i;
                aa.x = itemXY[i][0] - 14 + 16;
                aa.y = itemXY[i][1] - 14 + 46 + 12;
                aa.x = aa.x + 7;
                aa.name = String(i);
                if (value && value[i] != 0)
                {
                    aa.data = ItemObject.create(this.cfgitem[value[i]]);
                    j;
                    while (j < value.length)
                    {
                        
                        btn = new Button();
                        btn.skin = "png.common.btn_active";
                        btn.label = "升级";
                        btn.labelColors = "0xe09e20,0xf2d14b,0x685a23";
                        btn.labelFont = "Simsun";
                        btn.labelStroke = "1";
                        btn.name = String(j);
                        btn.clickHandler = new Handler(this.shengjiHandler, [value[i], i]);
                        btn.x = btnXY[i][0] + 12;
                        btn.y = btnXY[i][1] + 57 + 3;
                        count = ItemUilt.getAllCount(value[i]);
                        if (count >= 2)
                        {
                            this.play(btn);
                        }
                        else
                        {
                            this.stop(btn);
                        }
                        this.btnSprite.addChild(btn);
                        if (i == 0)
                        {
                            btn.visible = false;
                        }
                        else if (this.cfgitem[value[i]].level >= 10)
                        {
                            btn.visible = false;
                        }
                        else
                        {
                            btn.visible = true;
                        }
                        j = (j + 1);
                    }
                }
                this._itemprite.addChild(aa);
                aa.addEventListener(MouseEvent.CLICK, function (event:MouseEvent) : void
            {
                var _loc_2:* = int(event.currentTarget.name);
                var _loc_3:* = new Output();
                _loc_3.writeVarInt(curSelect, false);
                _loc_3.writeVarInt(_loc_2, false);
                PluginManager.instance.sendToBufferServer("baoshi", CMDBaoShi.ZhaiChu, _loc_3);
                return;
            }// end function
            );
                i = (i + 1);
            }
            this.showMask();
            return;
        }// end function

        private function play(param1:Button) : void
        {
            if (this.fgOjbs[param1.name])
            {
                (this.fgOjbs[param1.name] as TweenMax).kill();
            }
            param1.filters = [];
            this.fgOjbs[param1.name] = TweenMax.to(param1, 1, {glowFilter:{color:16763904, alpha:1, blurX:4, blurY:4, strength:2}, repeat:int.MAX_VALUE, yoyo:true});
            return;
        }// end function

        private function stop(param1:Button) : void
        {
            if (this.fgOjbs[param1.name])
            {
                (this.fgOjbs[param1.name] as TweenMax).kill();
            }
            param1.filters = [];
            return;
        }// end function

        private function showNBvalue() : void
        {
            var _loc_3:Array = null;
            var _loc_4:int = 0;
            var _loc_1:int = 0;
            var _loc_2:int = 0;
            while (_loc_2 < this.kaiqiArrs.length)
            {
                
                _loc_3 = this.kaiqiArrs[_loc_2].itemidList;
                _loc_4 = 0;
                while (_loc_4 < _loc_3.length)
                {
                    
                    if (_loc_3[_loc_4] != 0)
                    {
                        _loc_1 = _loc_1 + int(this.cfgitem[_loc_3[_loc_4]].nbvalue);
                    }
                    _loc_4++;
                }
                _loc_2++;
            }
            this.mPowerNumber.number = _loc_1;
            ModelProxy.change("data", "baoshi", this.kaiqiArrs);
            return;
        }// end function

        private function showMask() : void
        {
            var _loc_2:Array = null;
            var _loc_3:int = 0;
            var _loc_4:int = 0;
            var _loc_1:int = 0;
            while (_loc_1 < this.kaiqiArrs.length)
            {
                
                _loc_2 = [];
                _loc_3 = 0;
                if (this.xqItemIds && this.xqItemIds[_loc_1])
                {
                    _loc_4 = 0;
                    while (_loc_4 < this.xqItemIds[_loc_1].length)
                    {
                        
                        if (this.xqItemIds[_loc_1][_loc_4] && this.xqItemIds[_loc_1][_loc_4] != 0)
                        {
                            _loc_2.push(this.xqItemIds[_loc_1][_loc_4]);
                        }
                        _loc_4++;
                    }
                }
                _loc_3 = _loc_2.length;
                if (_loc_3 > 0)
                {
                    this["arm" + (_loc_1 + 1)].mask = this["arm" + (_loc_1 + 1) + "_mask"];
                    this["arm" + (_loc_1 + 1) + "_mask"].y = 3 + 62 - _loc_3 / 6 * 62;
                    this["ding" + (_loc_1 + 1)].y = this["arm" + (_loc_1 + 1) + "_mask"].y + 1;
                }
                else
                {
                    this["arm" + (_loc_1 + 1)].mask = null;
                    this["arm" + (_loc_1 + 1) + "_mask"].y = 0;
                }
                _loc_1++;
            }
            return;
        }// end function

        public function get sjview() : BaoShiSJView
        {
            if (this._sjview == null)
            {
                this._sjview = new BaoShiSJView();
                this._sjview.x = 523;
                this._sjview.y = 13;
                this._sjview.visible = false;
                this.addChild(this._sjview);
            }
            return this._sjview;
        }// end function

        private function shengjiHandler(param1:int, param2:int) : void
        {
            this.isShengji = 1;
            this.sjview.showItem(param1);
            this.checkHandler(param1);
            this.sjview.checkbox.clickHandler = new Handler(this.checkHandler, [param1]);
            this.sjview.upBtn.clickHandler = new Handler(this.upHandler, [param2]);
            this.sjview.visible = true;
            return;
        }// end function

        private function checkHandler(param1:int) : void
        {
            var _loc_3:Object = null;
            var _loc_4:int = 0;
            var _loc_5:int = 0;
            var _loc_2:int = 0;
            for each (_loc_3 in this.cfgGem)
            {
                
                if (int(_loc_3.itemid) == param1)
                {
                    _loc_2 = _loc_3.costnum;
                }
            }
            this.sjview.yuaobaoLabel.text = "需要元宝：0";
            if (this.sjview.checkbox.selected)
            {
                _loc_4 = ItemUilt.getAllCount(param1);
                if (_loc_4 < (_loc_2 - 1))
                {
                    _loc_5 = this.cfgGem[param1].storeid;
                    this.sjview.yuaobaoLabel.text = "需要元宝：" + String((_loc_2 - _loc_4 - 1) * int(this.cfgStore[_loc_5].nowprice));
                }
            }
            else
            {
                this.sjview.yuaobaoLabel.text = "需要元宝：0";
            }
            return;
        }// end function

        private function upHandler(param1:int) : void
        {
            var _loc_2:* = new Output();
            _loc_2.writeVarInt(this.curSelect, false);
            _loc_2.writeVarInt(param1, false);
            _loc_2.writeBoolean(this.sjview.checkbox.selected);
            PluginManager.instance.sendToBufferServer("baoshi", CMDBaoShi.ShengJi, _loc_2);
            return;
        }// end function

        protected function doClick(event:MouseEvent) : void
        {
            var _loc_4:int = 0;
            var _loc_2:* = ModelProxy.getValue("data", "roledata");
            var _loc_3:* = event.target.name;
            if (_loc_3.indexOf("pos_") >= 0)
            {
                _loc_4 = int(_loc_3.substr(4));
                this.doShow((_loc_4 - 1));
            }
            return;
        }// end function

        private function doShow(param1:int) : void
        {
            if (this._sjview)
            {
                this._sjview.visible = false;
            }
            var _loc_2:* = this.getChildByName("pos_" + (param1 + 1)) as Box;
            if (this.kaiqiArrs[param1])
            {
                if (this.img_glow)
                {
                    this.img_glow.x = _loc_2.x - 117;
                    this.img_glow.y = _loc_2.y - 115;
                }
                if (this.curSelect != param1)
                {
                    this.curSelect = param1;
                    this.showItem(this.xqItemIds[this.curSelect]);
                    this.showBagItem();
                }
            }
            return;
        }// end function

        public function showBagItem() : void
        {
            var _loc_5:int = 0;
            var _loc_6:ItemObject = null;
            var _loc_8:Object = null;
            var _loc_9:int = 0;
            var _loc_1:* = UserData.getUserData("career");
            var _loc_2:* = UserData.getBagData();
            var _loc_3:* = _loc_2.maxcount;
            var _loc_4:Array = [];
            _loc_5 = 1;
            while (_loc_5 < _loc_3)
            {
                
                _loc_8 = _loc_2[_loc_5];
                if (_loc_8)
                {
                    if (_loc_8[4] && int(_loc_8[4].itemtype) == 2 && int(_loc_8[4].cls) == 14)
                    {
                        _loc_9 = int((_loc_8[4].itemid as String).substr(7, 2));
                        if (_loc_1 == 1)
                        {
                            if (_loc_9 <= 10 || _loc_9 >= 31)
                            {
                                _loc_6 = ItemObject.create(_loc_8[4]);
                                _loc_6.count = _loc_8[1];
                                _loc_4.push(_loc_6);
                            }
                        }
                        else if (_loc_1 == 2)
                        {
                            if (_loc_9 > 10 && _loc_9 <= 20 || _loc_9 >= 31)
                            {
                                _loc_6 = ItemObject.create(_loc_8[4]);
                                _loc_6.count = _loc_8[1];
                                _loc_4.push(_loc_6);
                            }
                        }
                        else if (_loc_1 == 3)
                        {
                            if (_loc_9 > 20 && _loc_9 <= 30 || _loc_9 >= 31)
                            {
                                _loc_6 = ItemObject.create(_loc_8[4]);
                                _loc_6.count = _loc_8[1];
                                _loc_4.push(_loc_6);
                            }
                        }
                    }
                }
                _loc_5++;
            }
            while (_loc_4.length < 15)
            {
                
                _loc_4.push({index:_loc_4.length});
            }
            var _loc_7:* = _loc_4.length % 5;
            if (_loc_4.length % 5 > 0)
            {
                _loc_5 = 0;
                while (_loc_5 < 5 - _loc_7)
                {
                    
                    _loc_4.push({index:_loc_4.length});
                    _loc_5++;
                }
            }
            bagList.array = _loc_4;
            return;
        }// end function

        private function bagListRender(param1:BaoShiCtrl, param2:Component, param3:int) : void
        {
            var _loc_4:Object = null;
            var _loc_5:String = null;
            var _loc_6:int = 0;
            if (param3 < bagList.length)
            {
                _loc_4 = bagList.array[param3];
                if (!_loc_4.itemid)
                {
                    (param2 as FlashItem).data = null;
                    return;
                }
                (param2 as FlashItem).data = _loc_4;
                _loc_5 = String(_loc_4.itemid);
                _loc_6 = int(_loc_5.substr(7, 2));
                if (_loc_6 <= 30)
                {
                    this.xqindex = 1;
                }
                else if (_loc_6 > 30 && _loc_6 <= 40)
                {
                    this.xqindex = 2;
                }
                else if (_loc_6 > 40 && _loc_6 <= 50)
                {
                    this.xqindex = 3;
                }
                else if (_loc_6 > 50 && _loc_6 <= 60)
                {
                    this.xqindex = 4;
                }
                else if (_loc_6 > 60 && _loc_6 <= 70)
                {
                    this.xqindex = 5;
                }
                else
                {
                    this.xqindex = 0;
                }
                if (GuideView.getInstance().checkIsDo(GuideType.GUIDE_LINSHIGB) && param3 == 0 && param1.visible)
                {
                    if (this.kaiqiArrs.length > 0)
                    {
                        ModelProxy.change("guideitem", "guideid" + GuideType.GUIDE_LINSHI, param2);
                        GuideView.getInstance().doGuide(GuideType.GUIDE_LINSHI);
                    }
                }
            }
            return;
        }// end function

        private function hechengHandler(event:MouseEvent) : void
        {
            var e:* = event;
            Alert2.show("该操作会将背包中所有同类灵石合成至可合成的最高等级，是否确认？", "确认", ["确认", "取消"], function (param1:int, param2:Object) : void
            {
                var _loc_3:Object = null;
                var _loc_4:Array = null;
                var _loc_5:int = 0;
                var _loc_6:Boolean = false;
                var _loc_7:int = 0;
                var _loc_8:Object = null;
                var _loc_9:Object = null;
                var _loc_10:Output = null;
                if (param1 == 0)
                {
                    _loc_3 = UserData.getBagData();
                    _loc_4 = [];
                    _loc_5 = _loc_3.maxcount - _loc_3.emptycount;
                    _loc_7 = 1;
                    while (_loc_7 < _loc_3.maxcount)
                    {
                        
                        _loc_8 = _loc_3[_loc_7];
                        if (_loc_8)
                        {
                            if (_loc_8[4] && _loc_8[4].leixing == "灵石")
                            {
                                _loc_4.push(_loc_8);
                            }
                        }
                        _loc_7++;
                    }
                    _loc_6 = false;
                    _loc_7 = 0;
                    while (_loc_7 < _loc_4.length)
                    {
                        
                        for each (_loc_9 in cfgGem)
                        {
                            
                            if (_loc_4[_loc_7][0] == _loc_9.itemid)
                            {
                                if (_loc_4[_loc_7][1] >= int(_loc_9.costnum))
                                {
                                    _loc_6 = true;
                                    break;
                                }
                            }
                        }
                        _loc_7++;
                    }
                    if (_loc_6)
                    {
                        _loc_10 = new Output();
                        PluginManager.instance.sendToBufferServer("baoshi", CMDBaoShi.AskHeCheng, _loc_10);
                    }
                    else
                    {
                        ModelProxy.change("movetips", "error", "背包内同种宝石不足！");
                    }
                }
                return;
            }// end function
            );
            return;
        }// end function

        public function heChengSuccess(param1:Object) : void
        {
            var _loc_3:Object = null;
            if (!this.hechengView)
            {
                this.hechengView = new BaoShiHeChengUICtrl();
                this.hechengView.x = 810 - this.hechengView.width >> 1;
                this.hechengView.y = 515 - this.hechengView.height >> 1;
                this.hechengSprite.addChild(this.hechengView);
            }
            var _loc_2:String = "";
            for each (_loc_3 in param1)
            {
                
                if (_loc_3.num > 0)
                {
                    _loc_2 = _loc_2 + ("<font color=\'" + MColor.getqualitycolor(this.cfgitem[_loc_3.id].quality) + "\'>" + this.cfgitem[_loc_3.id].name + "*" + _loc_3.num + "</font>\n");
                }
            }
            this.hechengView.bsNameLabel.text = _loc_2;
            this.hechengView.closeBtn.addEventListener(MouseEvent.CLICK, this.closeHeChengHandler);
            this.hechengView.sureBtn.addEventListener(MouseEvent.CLICK, this.closeHeChengHandler);
            if (this._mc)
            {
                this._mc.playFromTo(-1, (this._mc.totalFrame - 1), new Handler(this.doEnd1));
                this._mc.visible = true;
            }
            this.showBagItem();
            return;
        }// end function

        private function doEnd1() : void
        {
            this._mc.stop();
            this._mc.visible = false;
            return;
        }// end function

        private function closeHeChengHandler(event:MouseEvent) : void
        {
            if (this.hechengView)
            {
                this.hechengView.bsNameLabel.text = "";
                if (this.hechengView.parent)
                {
                    this.hechengView.parent.removeChild(this.hechengView);
                    this.hechengView = null;
                }
            }
            return;
        }// end function

        private function showGouMaiItem() : void
        {
            var _loc_2:Array = null;
            var _loc_1:* = ModelProxy.getValue("data", "user.career");
            if (_loc_1 == 1)
            {
                _loc_2 = [241402003, 241402033, 241402043, 241402053, 241402063];
            }
            else if (_loc_1 == 2)
            {
                _loc_2 = [241402013, 241402033, 241402043, 241402053, 241402063];
            }
            else
            {
                _loc_2 = [241402023, 241402033, 241402043, 241402053, 241402063];
            }
            goumaiList.array = _loc_2;
            return;
        }// end function

        private function goumaiRender(param1:Component, param2:int) : void
        {
            var _loc_3:FlashItem = null;
            var _loc_4:Label = null;
            var _loc_5:Label = null;
            var _loc_6:Button = null;
            var _loc_7:Object = null;
            var _loc_8:Object = null;
            var _loc_9:Object = null;
            if (param2 < goumaiList.length)
            {
                _loc_3 = param1.getChildByName("item1") as FlashItem;
                _loc_3.data = ItemObject.create(this.cfgitem[goumaiList.array[param2]]);
                _loc_4 = param1.getChildByName("name") as Label;
                _loc_4.text = this.cfgitem[goumaiList.array[param2]].name;
                _loc_5 = param1.getChildByName("money") as Label;
                _loc_6 = param1.getChildByName("gouBtn") as Button;
                for each (_loc_7 in this.cfgStore)
                {
                    
                    if (int(_loc_7.itemid) == goumaiList.array[param2])
                    {
                        _loc_8 = _loc_7;
                        _loc_9 = ItemObject.create(this.cfgitem[_loc_8.itemid]);
                        _loc_5.text = _loc_7.nowprice;
                        _loc_6.removeEventListener(MouseEvent.CLICK, this.ItemClickHandler);
                        _loc_6.addEventListener(MouseEvent.CLICK, this.ItemClickHandler);
                        _loc_6.clickHandler = new Handler(this.goumaiHandler, [{msg:_loc_8, item:_loc_9}]);
                        break;
                    }
                }
            }
            return;
        }// end function

        protected function ItemClickHandler(event:MouseEvent) : void
        {
            var _loc_2:Object = null;
            var _loc_3:Object = null;
            var _loc_4:Object = null;
            var _loc_5:Object = null;
            if (event.currentTarget && event.currentTarget.parent)
            {
                _loc_2 = (event.currentTarget.parent as Component).dataSource;
                for each (_loc_3 in this.cfgStore)
                {
                    
                    if (int(_loc_3.itemid) == _loc_2)
                    {
                        _loc_4 = _loc_3;
                        _loc_5 = ItemObject.create(this.cfgitem[_loc_4.itemid]);
                        DialogMgr.instance.open(AppDialog.SC_BUY, {msg:_loc_4, item:_loc_5});
                        break;
                    }
                }
            }
            return;
        }// end function

        private function goumaiHandler(param1:Object) : void
        {
            DialogMgr.instance.open(AppDialog.SC_BUY, param1);
            return;
        }// end function

        private function closeHandler(event:MouseEvent) : void
        {
            ModelProxy.change("guide", "hide", GuideType.GUIDE_LINSHI);
            rightBox.visible = false;
            hechengBtn.visible = false;
            return;
        }// end function

        private function overHandler(event:MouseEvent) : void
        {
            var _loc_3:int = 0;
            var _loc_4:Boolean = false;
            var _loc_5:String = null;
            var _loc_6:int = 0;
            var _loc_7:String = null;
            var _loc_8:Array = null;
            var _loc_9:Array = null;
            var _loc_10:int = 0;
            var _loc_11:String = null;
            var _loc_12:Array = null;
            var _loc_13:String = null;
            var _loc_14:Boolean = false;
            var _loc_15:Object = null;
            var _loc_16:Array = null;
            var _loc_17:Object = null;
            var _loc_18:int = 0;
            var _loc_19:int = 0;
            var _loc_20:String = null;
            var _loc_21:int = 0;
            var _loc_22:int = 0;
            var _loc_2:* = event.currentTarget.name;
            if (_loc_2 == "tips")
            {
                this.showBuffer();
            }
            else if (_loc_2.indexOf("pos_") >= 0)
            {
                _loc_3 = int(_loc_2.substr(4)) - 1;
                _loc_4 = false;
                _loc_5 = "";
                if (this.kaiqiArrs)
                {
                    _loc_6 = 0;
                    while (_loc_6 < this.kaiqiArrs.length)
                    {
                        
                        if (_loc_3 == this.kaiqiArrs[_loc_6].pos)
                        {
                            this.tipsView.visible = true;
                            this.tipsView.showItem(_loc_3, this.xqItemIds[_loc_3]);
                            this.tipsView.x = (event.currentTarget as Box).x + 65;
                            this.tipsView.y = (event.currentTarget as Box).y + 35;
                            _loc_4 = true;
                            break;
                        }
                        _loc_6++;
                    }
                }
                if (!_loc_4)
                {
                    _loc_7 = this.cfgGemLimit[_loc_3].limit;
                    _loc_8 = [];
                    _loc_9 = [];
                    if (_loc_7.indexOf("&") > -1)
                    {
                        _loc_12 = (this.cfgGemLimit[_loc_3].limit as String).split("&");
                        _loc_8 = (_loc_12[0] as String).split("#");
                        _loc_9 = (_loc_12[1] as String).split("#");
                    }
                    else
                    {
                        _loc_8 = (_loc_7 as String).split("#");
                    }
                    _loc_10 = int(_loc_8[1]);
                    if (_loc_9)
                    {
                        _loc_13 = _loc_9[1];
                    }
                    _loc_11 = "";
                    if (_loc_10 > 0)
                    {
                        _loc_14 = ItemUilt.checkUserLevelRein(_loc_10);
                        if (_loc_14)
                        {
                            _loc_11 = MColor.getColor(7);
                        }
                        else
                        {
                            _loc_11 = MColor.getColor(9);
                        }
                        _loc_5 = "<font color=\'#9c7d5a\'>未开启\n需要角色等级：</font><font color=\'" + _loc_11 + "\'>" + _loc_10 + "级</font>\n";
                    }
                    if (_loc_13)
                    {
                        _loc_15 = ModelProxy.getValue("data", "baoshiTianguanProgress");
                        _loc_16 = ConfigDictionary.data.juezhantianguan;
                        if (_loc_15)
                        {
                            _loc_17 = _loc_16[_loc_15[0]][_loc_15[1]];
                            _loc_18 = 0;
                            _loc_19 = 0;
                            if (int(_loc_17.smallid) == 1)
                            {
                                _loc_18 = int(_loc_17.id) - 1;
                                _loc_19 = 20;
                            }
                            else
                            {
                                _loc_18 = int(_loc_17.id);
                                _loc_19 = int(_loc_17.smallid) - 1;
                            }
                            _loc_20 = "";
                            _loc_21 = int(_loc_13.charAt(0));
                            _loc_22 = int(_loc_13.substr(1, (_loc_13.length - 1)));
                            if (_loc_18 > _loc_21 || _loc_18 == _loc_21 && _loc_19 >= _loc_22)
                            {
                                _loc_20 = MColor.getColor(7);
                            }
                            else
                            {
                                _loc_20 = MColor.getColor(9);
                            }
                            _loc_5 = _loc_5 + ("<font color=\'#9c7d5a\'>通关三界之塔：</font><font color=\'" + _loc_20 + "\'>" + "第" + _loc_21 + "重第" + _loc_22 + "层</font>");
                        }
                    }
                    ModelProxy.change("tips", "normal", _loc_5);
                }
            }
            return;
        }// end function

        private function showBuffer() : void
        {
            var _loc_1:* = ModelProxy.getValue("data", "baoshi");
            this.getBstz(_loc_1);
            ModelProxy.change("tips", "normal", {data:this._bstzTips, p:new Point(2, 2)});
            return;
        }// end function

        private function getBstz(param1:Array) : void
        {
            var _loc_4:String = null;
            var _loc_6:int = 0;
            var _loc_7:Object = null;
            var _loc_8:String = null;
            var _loc_9:int = 0;
            var _loc_10:int = 0;
            var _loc_11:Object = null;
            var _loc_12:int = 0;
            var _loc_13:Object = null;
            var _loc_2:Object = null;
            var _loc_3:Object = null;
            var _loc_5:int = 0;
            for each (_loc_7 in this.bstz)
            {
                
                _loc_9 = 2;
                _loc_10 = 0;
                for each (_loc_11 in param1)
                {
                    
                    _loc_6 = 0;
                    while (_loc_6 < _loc_11.itemidList.length)
                    {
                        
                        if (_loc_11.itemidList[_loc_6] > 0 && int(this.cfgitem[_loc_11.itemidList[_loc_6]].level) >= int(_loc_7.lv))
                        {
                            _loc_10 = _loc_10 + 1;
                        }
                        _loc_6++;
                    }
                }
                if (_loc_10 >= int(_loc_7.count))
                {
                    _loc_5 = _loc_7.id;
                    _loc_9 = 8;
                    if (_loc_3 == null)
                    {
                        _loc_3 = new Object();
                    }
                    _loc_3.count = _loc_7.count;
                    _loc_3.lv = _loc_7.lv;
                    for (_loc_4 in _loc_7)
                    {
                        
                        if (_loc_4 == "id" || _loc_4 == "count" || _loc_4 == "lv")
                        {
                            continue;
                        }
                        if (_loc_3[_loc_4] == null)
                        {
                            _loc_3[_loc_4] = 0;
                        }
                        _loc_3[_loc_4] = int(_loc_7[_loc_4]);
                    }
                    continue;
                }
                if (_loc_2 == null)
                {
                    _loc_2 = new Object();
                    for (_loc_4 in _loc_7)
                    {
                        
                        if (_loc_4 == "id" || _loc_4 == "count" || _loc_4 == "lv")
                        {
                            _loc_2[_loc_4] = int(_loc_7[_loc_4]);
                            continue;
                        }
                        _loc_2[_loc_4] = int(_loc_7[_loc_4]);
                    }
                    break;
                }
            }
            _loc_8 = "<font color=\'" + MColor.Newstr82 + "\' size=\'14\'>灵石属性效果</font>\n";
            _loc_8 = _loc_8 + MColor.getHMTL("\n当前效果:\n", 55);
            if (_loc_3 == null)
            {
                _loc_8 = _loc_8 + MColor.getHMTL("无\n", 65);
            }
            else
            {
                _loc_8 = _loc_8 + MColor.getHMTL("镶嵌" + _loc_3.count + "颗" + _loc_3.lv + "级灵石", 83);
                _loc_8 = _loc_8 + ("<font color=\'#53b436\'>  (" + _loc_3.count + "/" + _loc_3.count + ")(激活)</font>\n");
                _loc_8 = _loc_8 + ("<font color=\'#53b436\'>生命 +" + _loc_3.hpaddper / 100 + "%</font>\n");
                _loc_8 = _loc_8 + ("<font color=\'#53b436\'>神圣攻击 +" + _loc_3.pureatk + "</font>");
            }
            if (_loc_2)
            {
                _loc_8 = _loc_8 + MColor.getHMTL("\n下级效果:\n", 55);
                _loc_8 = _loc_8 + MColor.getHMTL("镶嵌" + _loc_2.count + "颗" + _loc_2.lv + "级灵石", 4);
                _loc_12 = 0;
                for each (_loc_13 in param1)
                {
                    
                    _loc_6 = 0;
                    while (_loc_6 < _loc_13.itemidList.length)
                    {
                        
                        if (_loc_13.itemidList[_loc_6] > 0 && int(this.cfgitem[_loc_13.itemidList[_loc_6]].level) >= int(_loc_7.lv))
                        {
                            _loc_12 = _loc_12 + 1;
                        }
                        _loc_6++;
                    }
                }
                _loc_8 = _loc_8 + ("<font color=\'#ff0000\'>  (" + _loc_12 + "/" + _loc_2.count + ")(未激活)</font>\n");
                _loc_8 = _loc_8 + ("<font color=\'#94928c\'>生命 +" + _loc_2.hpaddper / 100 + "%</font>\n");
                _loc_8 = _loc_8 + ("<font color=\'#94928c\'>神圣攻击 +" + _loc_2.pureatk + "</font>");
            }
            this._bstzTips = _loc_8;
            return;
        }// end function

        private function outHandler(event:MouseEvent) : void
        {
            if (this.tipsView)
            {
                this.tipsView.visible = false;
            }
            ModelProxy.change("tips", "state", "close");
            return;
        }// end function

        public function clearSelectEffect() : void
        {
            if (this.img_glow)
            {
                if (this.img_glow.parent)
                {
                    this.img_glow.parent.removeChild(this.img_glow);
                }
                this.img_glow.stop();
            }
            return;
        }// end function

    }
}
